home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17847 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mozo.cc.purdue.edu!news
  2. From: hillca@cs.purdue.edu (Chris Hill)
  3. Newsgroups: comp.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.lang.c++
  4. Subject: Re: [Q] Why doesn't this compile?
  5. Date: 17 Apr 1996 19:43:47 GMT
  6. Organization: Purdue University
  7. Message-ID: <4l3hlj$6qt@mozo.cc.purdue.edu>
  8. References: <317523C0.5042@eps.agfa.be>
  9. NNTP-Posting-Host: lab40.cs.purdue.edu
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. In article <317523C0.5042@eps.agfa.be>, rorlic@eps.agfa.be says...
  15. >test.cpp(18) : error C2352: 'A::L::f' : illegal call of 
  16. >nonstatic member function
  17. >Error executing cl.exe.
  18. >test.obj - 1 error(s), 1 warning(s)
  19. >
  20. >------------------------------------------------
  21. >
  22. >Anybody knows what's wrong with it?
  23. >Thanks,
  24. >
  25. >-- Ranko.
  26.  
  27. I think the error message is telling you exactly what is wrong.  You can't call 
  28. A::L::f because it is not a static function.  A static function is shared 
  29. between all instances of the class (it only has access to other static 
  30. members), while nonstatic functions all have have access to  the instance 
  31. specific data of the class. 
  32.  
  33. A::L::f requires that f is a static function.  Which A object do you expect the 
  34. compiler to call f for?
  35.  
  36. -- 
  37. Chris Hill
  38. hillca@cs.purdue.edu
  39.  
  40.